<?php

namespace App\Http\Resources;

use App\Models\PmProjectBasic;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class PmProjectListResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  Request              $request
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'project_name' => $this->project_name,
            'project_code' => $this->project_code,
            'foundation' => $this->foundation,
            'foundation_text' => $this->foundation_text,
            'field' => $this->field,
            'field_text' => $this->field_text,
            'category' => $this->category,
            'category_text' => $this->category_text,
            'project_status' => $this->project_status,
            'project_status_text' => PmProjectBasic::$statusMapping[$this->project_status] ?? '未知',
            'setup_date' => $this->setup_date,
            'complete_date' => $this->complete_date,
            'direct_donate_budget' => $this->direct_donate_budget,
            'activity_cost_budget' => $this->activity_cost_budget,
            'budget' => $this->budget,
            'cooperate_amount' => $this->cooperate_amount,
            'payment_amount' => $this->payment_amount,
            'department_name' => $this->department_name,
            'charger' => $this->charger,
            'charger_text' => $this->charger_text,
            'creator' => $this->creator,
            'creator_text' => $this->creator_text,
            'created_at' => $this->created_at->toDateTimeString(),
            'updated_at' => $this->updated_at->toDateTimeString(),
        ];
    }
}
